#include<iostream>
int temp[1010];
int fun(int arr[],int l, int r)
{   
	if (l == r) {
		return 1;
	}
	int mid = (l + r) >> 1;
	int ans = fun(arr, l, mid) + fun(arr, mid + 1, r);
	int i = l;
	int j = mid + 1;
	int k = 0;
	while (i <= mid && j <= r) {
		if (arr[i] <= arr[j]) {
			temp[k++] = arr[i++];
		}
		else {
			temp[k++] = arr[j++];
			ans += j - l + 1;
		}
	}
	while (i <= mid) {
		temp[k++] = arr[i++];
	}
	while (j <= r) {
		temp[k++] = arr[j++];
	}
	for (int i = l, j = 0; i <= r; i++, j++) {
		arr[i] = temp[j];
	}
}
using namespace std;
int main()
{
	//int arr[] = { 1,4,2,6,8,10,23,4,2,5 };
	int arr[] = { 2,3,4,1 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int ret = fun(arr, 0, sz - 1);
	cout << ret << endl;
	return 0;
}